<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<c:set var="base" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>设备管理</title>
  <link href="${base}/assets/css/iconfont.css" rel="stylesheet">
  <link href="${base}/assets/css/public.css" rel="stylesheet">
  <link href="${base}/assets/css/list.css" rel="stylesheet">
  <script src="${base}/assets/js/jquery.min.js"></script>
  <script type="text/javascript" src="${base}/assets/js/jquery.PrintArea.js"></script>
  <link rel="stylesheet" type="text/css" href="${base}/assets/easyui/themes/gray/easyui.css" />
	<link rel="stylesheet" type="text/css" href="${base}/assets/easyui/themes/icon.css" />
	<script type="text/javascript" src="${base}/assets/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${base}/assets/easyui/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="${base}/assets/js/zingchart.min.js"></script>
  <style>
	#pageshow{
		height:40px;
		padding-left: 30%;
	}
	#pageshow a{
		float:left;
		    text-decoration: none;
		font-family: consolas;
	}
	#pageshow span{
		margin-left: 5px;
		font-size: 15px;
	}
	#pageshow input{
		width: 25px;
	}
	
	#pagenum{
		float:left;
	}
	#printdiv span{
		
	}
	#printdiv img{
		margin: 10px 0;
	}
	.black_overlay{
		display: none;
		position: absolute;
		top: 0%;
		left: 0%;
		width: 100%;
		height: 100%;
		background-color: black;
		z-index:1001;
		-moz-opacity: 0.8;
		opacity:.85;
		filter: alpha(opacity=85);
	}
	.white_content {
		display: none;
		position: fixed;
		top: 10%;
		left: 10%;
		width: 80%;
		height: 80%;
		
		background-color: white;
		z-index:1002;
		overflow: auto;
	}
	.white_content_small {
		display: none;
		position: absolute;
		top: 20%;
		left: 30%;
		width: 40%;
		height: 50%;
		border: 16px solid lightblue;
		background-color: white;
		z-index:1002;
		overflow: auto;
	}
	.textbox{
		height: 30px !important;
		margin: 0 !important;
	}
	.textbox .textbox-addon{
		margin: 0;
	}
</style> 
</head>
<body>
<input type="hidden" id="pageNo" value="${pageNo}"/>
<div class="top">
<c:import url="../commons/top.jsp"/>
</div>
<div class="wrap">

  <div class="side">
  	<c:import url="../commons/sidebar.jsp"/>
  </div>
  <div id="tablist" class="cont" style="position:retative;">
  	<div class="fixed-header" style="position:fixed;top:0;left:10%;width:90%;background-color: #fff;">
	    <div class="bread">
	      <span>设备管理</span><span>&nbsp;&gt;&nbsp;</span><span>设备列表</span>
	      <c:if test="${admin.utype=='1'}">   
	      <div class="excel-add">
	        <div class="exl">
	          <label for="excel" class="fileBtn">+Excel导入</label>
	          <form action="${base}/back/readExcel.do" method="post" enctype ="multipart/form-data" id="uploadexcelform">
	          	<input type="file" id="excel" name="excelFile">
	          </form>
	        </div>
	        <a class="add" href="javascript:void(0)" onclick="addgo()">+添加</a>
	      </div>
	      </c:if>  
	      <div class="clear"></div>
	    </div>
	    <div class="cate">
	          <ul>
	              <li>
	                  <span>所在位置:</span>
	                  <select id="wid" name="wid">
			             <option value="">--请选择--</option>
			               <c:forEach items="${whlist}" var="w">
			                    <option value="${w.id}" <c:if test="${wid==w.id}">selected="selected"</c:if>>${w.whname}</option>
			           		</c:forEach>
			          </select>
	              </li>
	              <li>
	                  <span>设备类别:</span>
	                  <input id="searchbylike"  style="padding:6px 0;box-sizing: content-box;" value="${dcid}" placeholder="设备类别"/>
	              </li>
	              <li>
	                  <span>投产时间:</span>
	                  <input id="stcsj" class="easyui-datetimebox" value="${stcsj}" />
	              </li>
	              <li>
	                  <span>时间段:</span>
	                  <input id="stcsjd1" class="easyui-datetimebox" value="${stcsjd1}" />至	                  
	              </li>
	              <li style="width: 175px;">	                  
	                  <input id="stcsjd2" class="easyui-datetimebox"   value="${stcsjd2}"/>
	              </li>
	          </ul>
	          <!-- <button onclick="findbtn()" style="border:none;padding:6px 10px;margin: 6px 0 0 0;background-color:#337ab7;color: #fff;">搜索</button> -->
	      </div>
	    <div class="btn-site">
      <ul>
        <li class="on" onclick="seachfl('0');" id="0">全部</li>
        <li onclick="seachfl('1');" id="1">正常</li>
        <li onclick="seachfl('2');" id="2">出库</li>
        <li onclick="seachfl('3');" id="3">报废</li>
      </ul>
      <div class="clear"></div>
      <script type="text/javascript">
      	$(function(){
      		var statu='${status}';
      		$('.btn-site ul li').each(function(){
      		     if($(this).attr("id") == statu)
      		    	$(this).addClass('on').siblings().removeClass('on');
      		  });
		});
		function seachfl(val){
           		$(this).addClass('on').siblings().removeClass('on');
				var wid = $('#wid option:selected') .val();
				/* var cid = $('#cid option:selected') .val();
				var fcid= $('#fcid option:selected') .val(); */
				var dcid = encodeURI(encodeURI($('#searchbylike').val()));
				var stcsj = $("#stcsj").datetimebox("getValue").substring(0,10);
				var stcsjd1=$("#stcsjd1").datetimebox("getValue").substring(0,10);
				var stcsjd2=$("#stcsjd2").datetimebox("getValue").substring(0,10);
				var url = '${base}/back/devicelist.do?wid='+wid+'&dcid='+dcid+'&stcsj='+stcsj+'&stcsjd1='+stcsjd1+'&stcsjd2='+stcsjd2+'&status='+val;
				window.location.href=url;
			}
		function clickpx(type){
			var statu='${status}';
			var wid = $('#wid option:selected') .val();	
			var dcid = encodeURI(encodeURI($('#searchbylike').val()));
			var stcsj = $("#stcsj").datetimebox("getValue").substring(0,10);
			var stcsjd1=$("#stcsjd1").datetimebox("getValue").substring(0,10);
			var stcsjd2=$("#stcsjd2").datetimebox("getValue").substring(0,10);
			var url = '${base}/back/devicelist.do?wid='+wid+'&dcid='+dcid+'&stcsj='+stcsj+'&stcsjd1='+stcsjd1+'&stcsjd2='+stcsjd2+'&pxtype='+type+'&status='+statu;
			
			//var url = '${base}/back/devicelist.do?wid='+wid+'&dcid='+dcid+'&status='+statu+'&pxtype='+type;
			window.location.href=url;
		}
	</script>
    </div>
    </div>
    <table id="sample_editable_1" width="100%" border="1" cellspacing="0" cellpadding="0" bordercolor="#e9e9f0" class="list" style="margin-top:180px;">
      <thead>
        <tr style="background-color:#ccc;">
            <!-- <th>功能类别</th> -->
            <c:if test="${sblbpx== true}">
				<th onclick="clickpx('sblbpx');">设备类别<img style="width:10px" src="${base}/assets/img/shang.png" /></th>
			</c:if>
			<c:if test="${sblbpx==false}">
				<th onclick="clickpx('sblbpx');">设备类别<img style="width:10px" src="${base}/assets/img/xia.png" /></th>
			</c:if>
            <th>品    牌 </th> 
			<c:if test="${jbhpx== true}">
				<th onclick="clickpx('jbhpx');">旧  编  号<img style="width:10px" src="${base}/assets/img/shang.png" /></th>
			</c:if>
			<c:if test="${jbhpx==false}">
				<th onclick="clickpx('jbhpx');">旧  编  号<img style="width:10px" src="${base}/assets/img/xia.png" /></th>
			</c:if>
            
            <c:if test="${bhpx==true}">
				<th onclick="clickpx('bhpx');">编    号<img style="width:10px" src="${base}/assets/img/shang.png" /></th>
			</c:if>
			<c:if test="${bhpx==false}">
				<th onclick="clickpx('bhpx');">编    号<img style="width:10px" src="${base}/assets/img/xia.png" /></th>
			</c:if>
			
            <c:if test="${xhpx==true}">
				<th onclick="clickpx('xhpx');">型    号<img style="width:10px" src="${base}/assets/img/shang.png" /></th>
			</c:if>
			<c:if test="${xhpx==false}">
				<th onclick="clickpx('xhpx');">型    号<img style="width:10px" src="${base}/assets/img/xia.png" /></th>
			</c:if>
			
			<c:if test="${ccbhpx==true}">
				<th onclick="clickpx('ccbhpx');">出厂编号<img style="width:10px" src="${base}/assets/img/shang.png" /></th>
			</c:if>
			<c:if test="${ccbhpx==false}">
				<th onclick="clickpx('ccbhpx');">出厂编号<img style="width:10px" src="${base}/assets/img/xia.png" /></th>
			</c:if>
			
            <c:if test="${tcnypx==true}">
				<th onclick="clickpx('tcnypx');">投产年月<img style="width:10px" src="${base}/assets/img/shang.png" /></th>
			</c:if>
			<c:if test="${tcnypx==false}">
				<th onclick="clickpx('tcnypx');">投产年月<img style="width:10px" src="${base}/assets/img/xia.png" /> </th>
			</c:if>
			
			<c:if test="${zjnxpx==true}">
				<th onclick="clickpx('zjnxpx');">折旧年限<img style="width:10px" src="${base}/assets/img/shang.png" /></th>
			</c:if>
			<c:if test="${zjnxpx==false}">
				<th onclick="clickpx('zjnxpx');">折旧年限<img style="width:10px" src="${base}/assets/img/xia.png" /> </th>
			</c:if>
			
			<c:if test="${cgjapx==true}">
				<th onclick="clickpx('cgjapx');">采购价格<img style="width:10px" src="${base}/assets/img/shang.png" /></th>
			</c:if>
			<c:if test="${cgjapx==false}">
				<th onclick="clickpx('cgjapx');">采购价格<img style="width:10px" src="${base}/assets/img/xia.png" /> </th>
			</c:if> 
			
            <th>初始位置</th>
            <c:if test="${ckwzpx== true}">
				<th onclick="clickpx('ckwzpx');">当前位置<img style="width:10px" src="${base}/assets/img/shang.png" /></th>
			</c:if>
			<c:if test="${ckwzpx==false}">
				<th onclick="clickpx('ckwzpx');">当前位置<img style="width:10px" src="${base}/assets/img/xia.png" /></th>
			</c:if>
            <th>状    态</th>
            <th>备    注</th>
			<th>操    作</th>
         </tr>
      </thead>
      <tbody>
      </tbody>
    </table>
	<div id="pageshow">
		<a id="btn0"  style="font-size: 16px;margin-right:15px;"></a>
		<a href="#" id="btn1"  title="首页" style="font-size: 18px;margin-right:15px;"> << </a>
		<a href="#" id="btn2"  title="上一页" style="font-size: 18px;margin-right:15px;"> < </a>
		<div id="pagenum" ></div>
		<a href="#" id="btn3"  title="下一页" style="font-size: 18px;margin-right:15px;">&nbsp; > </a>
		<a href="#" id="btn4"  title="末页" style="font-size: 18px;margin-right:15px;"> >> </a>
		<a id="sjzl"  style="font-size: 16px;"></a>
		<span>跳转</span><input type="text" id="gopage"/><span>页</span><button id="gopagebtn" style="font-size: 14px"> go </button>
  </div>
	
	    <span style="float:left;">
		    <button onclick="loadExcel()" type="button" style="margin-left: 0 !important;">导出excel </button>
		    <c:if test="${admin.utype=='1'}">
		    	<button onclick="batchOperation()" type="button" style="margin-left: 0 !important;">批量操作 </button>
		    </c:if>
			<button onclick="ShowDiv('MyDiv','fade')" type="button" style="margin-left: 0 !important;">批量打印设备码</button>	      
		</span>
	
  <div class="clear"></div>
</div>
<script type="text/javascript">
$("#excel").on('change',function(event){
	if($(this).val() != ''){
		  var strExtension = $(this).val().substr($(this).val().lastIndexOf('.') + 1);
		  if (strExtension == 'xls' || strExtension == 'xlsx') {
		    document.getElementById("uploadexcelform").submit();
		    	$("#excel").replaceWith("<input type='file' id='excel' name='excelFile'>");
		  }else{
		    alert("请选择excle文件！");
		    return;
		  }
	}
});
$('#wid').change(function(){  
     findbtn();
})
$("#searchbylike").keypress(function (event) {
	//获取input输入的值
    if (event.keyCode == 13 || 32== event.keyCode) {
    	findbtn();
	}
});
 $('#stcsj').datetimebox({
	showSeconds:false,
     onSelect: function (value) {
		var y = value.getFullYear();  
	    var m = value.getMonth() + 1;  
	    var d = value.getDate();  
	     
	    var dateTime = y+"-"+(m<10?("0"+m):m)+"-"+(d<10?("0" + d):d);
	    $('#stcsj').datetimebox('setText', dateTime.substring(0,10)); 
	    $('#stcsj').datetimebox('setValue', dateTime.substring(0,10)); 
	    $('#stcsj').datetimebox('hidePanel');
		 if($("#stcsjd1").datetimebox("getValue")!=""|| $("#stcsjd1").datetimebox("getValue")!=null) {
			 $('#stcsjd1').datetimebox('setValue', '');
		 }
		 if($("#stcsjd2").datetimebox("getValue")!=""|| $("#stcsjd2").datetimebox("getValue")!=null) {
			 $('#stcsjd2').datetimebox('setValue', '');
		 }
		 findbtn();
    }
});

$("#stcsjd1").datetimebox({
	showSeconds:false,
	 onSelect: function (value) {
		var y = value.getFullYear();  
        var m = value.getMonth() + 1;  
        var d = value.getDate();  
         
        var dateTime = y+"-"+(m<10?("0"+m):m)+"-"+(d<10?("0" + d):d);
        $('#stcsjd1').datetimebox('setText', dateTime.substring(0,10)); 
        $('#stcsjd1').datetimebox('setValue', dateTime.substring(0,10)); 
	    $('#stcsjd1').datetimebox('hidePanel'); 
		
		if($("#stcsjd2").datetimebox("getValue")==""|| $("#stcsjd2").datetimebox("getValue")==null) {
			return;
		}
		$('#stcsj').datetimebox('setValue', '');
		findbtn();
    }
});
$("#stcsjd2").datetimebox({
	showSeconds:false,
	 onSelect: function (value) {
		var y = value.getFullYear();  
        var m = value.getMonth() + 1;  
        var d = value.getDate();  
         
        var dateTime = y+"-"+(m<10?("0"+m):m)+"-"+(d<10?("0" + d):d);
        $('#stcsjd2').datetimebox('setText', dateTime.substring(0,10)); 
        $('#stcsjd2').datetimebox('setValue', dateTime.substring(0,10)); 
	    $('#stcsjd2').datetimebox('hidePanel'); 
		
		 if($("#stcsjd1").datetimebox("getValue")==""|| $("#stcsjd1").datetimebox("getValue")==null) {
			return;
		 }
		 $('#stcsj').datetimebox('setValue', '');
		 findbtn();
    }
});

function findbtn(){
	var wid = $('#wid option:selected') .val();
	var dcid = encodeURI(encodeURI($('#searchbylike').val()));
	var stcsj = $("#stcsj").datetimebox("getValue").substring(0,10);
	var stcsjd1=$("#stcsjd1").datetimebox("getValue").substring(0,10);
	var stcsjd2=$("#stcsjd2").datetimebox("getValue").substring(0,10);
	var url = '${base}/back/devicelist.do?wid='+wid+'&dcid='+dcid+'&stcsj='+stcsj+'&stcsjd1='+stcsjd1+'&stcsjd2='+stcsjd2;
	window.location.href=url;
}
function addgo(){
	var url ="${base}/back/deviceadd.do?pageNo=" +$("#pageNo").val();
	window.location.href=url;
}
function loadExcel(){
	if(($("#sample_editable_1 tr").length - 1)<=0){
		alert("无数据不能导出excel");
		return;
	}
	var url ='${base}/back/exportExcel.do';
	window.open(url,"_self");
}
function batchOperation(){
	var url ='${base}/back/batchOperation.do';
	window.location.href=url;
}
function scandetaile(id){
	var url ='${base}/back/devicdetail.do?id='+id+"&pageNo="+$("#pageNo").val();
	window.location.href=url;
}
function deleteSingle(id){
	var mymessage=window.confirm('是否删除已报废设备！');  
    if(mymessage==true){ 
		var url = '${base}/back/deletebf.do?id='+id;
    	window.open(url,"_self");  
    }else if(mymessage==false){  
    	 return; 
    }
}
var printdata=null;
$(function(){

	/* $('#cid').searchableSelect();
	$('#fcid').searchableSelect();
	$('#dcid').searchableSelect(); */
	//$('#wid').searchableSelect();
	//$('#no').searchableSelect();
	
	var pageSize = 20;    //每页显示的记录条数
	var curPage=0;        //当前页
	var page;            //总页数
	var tapnum=10;		 //显示分页标签的个数
	var pagetag = new Array();
	display();
	
  function display(){//load时
		
	    len =${listlen};    // 求这个表的总行数，剔除第一行介绍
	    page= (len % pageSize==0) ? (len/ pageSize): (Math.floor(len/pageSize)+1);//根据记录条数，计算页数
	    curPage=parseInt($("#pageNo").val());    // 设置当前为第一页
	    
		for (var i = 1; i <= tapnum; i++) {
			$("#pagenum").append('<button id="dqjm_'+i+'" style="font-size: 14px"></button>');
			$("#dqjm_" + i).hide();
		}
		var bnum=0;
		var ednu=0;
		if(page<=tapnum){
			bnum=1
			ednu=page;
		}else{
			bnum = curPage;
			if(curPage+(tapnum-1) <= page){
				ednu= curPage+(tapnum-1);	
			}else{
				ednu = curPage + (page-curPage);
				bnum = curPage - (tapnum-(page-curPage+1));
				if(bnum<=0) bnum=1;
			}
		}
		
		var temnum=1;
		for (var i = bnum; i <= ednu; i++) {
			$("#dqjm_" + temnum).html(i.toString());
			$("#dqjm_" + temnum).show();
			if(i== curPage) $("#dqjm_" + temnum).css({'background-color':'#0086ff'});
			pagetag.push(i);
			temnum++;
			
		}
		displayPage(curPage);
	    $("#btn0").html("第 " + curPage + "页" +"   共"+ page + "页 ");    // 显示当前多少页
	    $("#sjzl").html("共计" + len + "条");        // 显示数据量  
 }
  
	$("#btn1").click(function firstPage(){    // 首页
        curPage=1;
		pagetag.splice(0,pagetag.length);
        for(var j=0;j<pageSize;j++){
			pagetag.push(j+1);
			$("#dqjm_" + (j+1)).html(j+1);
			if(j+1==curPage){
				$("#dqjm_" + (j+1)).css({'background-color':'#0086ff'});
			}else{
				$("#dqjm_" + (j+1)).css({'background-color':''});
			}
		}
		displayPage(curPage);
    });
    $("#btn2").click(function frontPage(){    // 上一页
		var tcpage= curPage-1; 
		var isint=false;
		var idx = -1;
		for(var i=0;i<pagetag.length;i++){
			if(pagetag[i]==tcpage){
				isint = true;
				idx = i;
				break;
			}
		}
		if(isint){
			curPage -=1;
			$("#pagenum > button").each(function (i){
				var sidx = parseInt(this.innerHTML);
				if(curPage != sidx) $(this).css({'background-color':''});
			});
			$("#dqjm_" + (idx+1)).css({'background-color':'#0086ff'});
		}else{
			if(tcpage>=1){
				curPage -=1;
				pagetag.pop();
				pagetag.splice(0,0,curPage);
				for(var j=0;j<pagetag.length;j++){
					$("#dqjm_" + (j+1)).html(pagetag[j]);
					if(pagetag[j]==curPage){
						$("#dqjm_" + (j+1)).css({'background-color':'#0086ff'});
					}else{
						$("#dqjm_" + (j+1)).css({'background-color':''});
					}
				}
			}else{
				curPage=1;
				alert("已经是第一页了");
				return;
			}
		}
		displayPage(curPage);
    });
    $("#btn3").click(function nextPage(){    // 下一页
		var tcpage= curPage+1; 
		var isint=false;
		var idx = -1;
		for(var i=0;i<pagetag.length;i++){
			if(pagetag[i]==tcpage){
				isint = true;
				idx = i;
				break;
			}
		}
		if(isint){
			curPage +=1;
			$("#pagenum > button").each(function (i){
				var sidx = parseInt(this.innerHTML);
				if(curPage != sidx) $(this).css({'background-color':''});
			});
			$("#dqjm_" + (idx+1)).css({'background-color':'#0086ff'});
		}else{
			if(tcpage<=page){
				curPage +=1;
				pagetag.shift();
				pagetag.push(pagetag[pagetag.length -1]+1);
				for(var j=0;j<pagetag.length;j++){
					$("#dqjm_" + (j+1)).html(pagetag[j]);
					if(pagetag[j]==curPage){
						$("#dqjm_" + (j+1)).css({'background-color':'#0086ff'});
					}else{
						$("#dqjm_" + (j+1)).css({'background-color':''});
					}
				}
			}else{
				curPage=page;
				alert("已经是最后一页了");
				return;
			}
		}
		displayPage(curPage);
    });
    $("#btn4").click(function lastPage(){    // 尾页
        curPage=page;
		pagetag.splice(0,pagetag.length);
		var temnum=1;
        for(var j=(page-tapnum+1);j<=page;j++){
			if(j<=0) continue;
			pagetag.push(j);
			$("#dqjm_" + temnum).html(j);
			if(j==curPage){
				$("#dqjm_" + temnum).css({'background-color':'#0086ff'});
			}else{
				$("#dqjm_" + temnum).css({'background-color':''});
			}
			temnum++;
		}
		displayPage(curPage);
    });
	$("#gopagebtn").click(function(){//点击跳转页
		var gonum = $("#gopage").val();
		if(gonum==null||gonum==''){
			alert("请输入跳转的页数！！");
			$("#gopage").val("");
			return;
		}
		var re = /^[1-9]+[0-9]*]*$/;
		if(!re.test(gonum)) {
　　　　	    alert("请输入数字！！");
			$("#gopage").val("");
　　　　	return false;
　　	}
		if(parseInt(gonum)>page){
			alert("超过最大页数！！");
			$("#gopage").val("");
			return false;
		}
		curPage=parseInt(gonum);
		pagetag.splice(0,pagetag.length);
		var bnum=0;
		var ednu=0;
		if(curPage+(tapnum-1) <= page){
			bnum=curPage;
			ednu= curPage+(tapnum-1);	
		}else{
			ednu = page;
			bnum = curPage - (tapnum-(page-curPage+1));
			if(bnum<=0) bnum=1;
		}
		var temnum=1;
		for (var i = bnum; i <= ednu; i++) {
			$("#dqjm_" + temnum).html(i.toString());
			$("#dqjm_" + temnum).show();
			if(i== curPage){ 
				$("#dqjm_" + temnum).css({'background-color':'#0086ff'});
			}else{
				$("#dqjm_" + temnum).css({'background-color':''});
			}
			pagetag.push(i);
			temnum++;
			
		}
		$("#gopage").val("");
		displayPage(curPage);
	});
    $("#pagenum > button").click(function firstPage(){    // 点击页标签 
        curPage=parseInt(this.innerHTML);
        $(this).css({'background-color':'#0086ff'});
        $("#pagenum > button").each(function (i){
        	var sidx = parseInt(this.innerHTML);
        	if(curPage != sidx) $(this).css({'background-color':''});
        });
        document.getElementById("btn0").innerHTML="第 " + curPage + "页" +"   共"+ page + "页 ";        // 显示当前多少页
		displayPage(curPage);
    });
	function displayPage(cpnum){
		var tstat = ${admin.utype};
		$("#pageNo").val(cpnum);
		$.ajax({
		  type: "POST",
		  dataType: "json", // 数据格式:JSON
		  url: '${base}/back/findddlist.do',
		  data: {pageNo:cpnum},
		  success: function (data) {
			if(data.ddlist != null){
				printdata = data.ddlist;
				$("#sample_editable_1 tbody").html("");
				$.each(data.ddlist,function(i,result){
					var tstr = "";
					if(result["status"]=='1'){
						tstr="正  常";
					}else if(result["status"]=='2'){
						tstr="已出库";
					}else if(result["status"]=='3'){
						tstr="已报废";
					}
					var item='<tr style="background-color:rgba(226, 223, 223);text-align:center;">'+
						/* '<td>'+result["cfname"]+'</td>'+ */
						'<td>'+result["cdname"]+'</td>'+
						'<td>'+result["brand"]+'</td>'+
						'<td>'+result["oldno"]+'</td>'+
						'<td>'+result["no"]+'</td>'+
						'<td>'+result["xhno"]+'</td>'+
						'<td>'+result["ccno"]+'</td>'+
						'<td>'+result["tcrq"].substring(0,10)+'</td>'+
						'<td>'+result["zjnx"]+'</td>'+
						'<td>'+result["cgjg"]+'</td>'+
						'<td>'+result["oriwhname"]+'</td>'+
						'<td>'+result["whname"]+'</td>'+
						'<td>'+tstr+'</td>'+
						'<td><a href="#" style="background: #4876FF" title=" '+result["remark"]+' ">'+result["remark"].substring(0,30)+'...</a></td>'+
						'<td><a href="javascript:;" onclick="scandetaile('+result["id"]+');"><i></i>详情</a>'; 
						if(result["status"]=='3'&& tstat=='1'){
							item +='<a href="javascript:;" onclick="deleteSingle('+result["id"]+');"><i></i> 删除 </a>';
						}
					item+='</td></tr>';
                	$("#sample_editable_1 tbody").append(item);
                })
			}
		  }
		});
	};
	var dt_buttons = $.extend([], $.fn.datetimebox.defaults.buttons);
    dt_buttons.splice(2,0,{
        text: '清空',
        handler: function(target){
            $(target).datetimebox('setValue','');
            findbtn();
        }
    });
    $('.easyui-datetimebox').datetimebox({
        buttons: dt_buttons,
        editable:false,
        width:'150px'
    });
    
});
function ShowDiv(show_div,bg_div){
	document.getElementById(show_div).style.display='block';
	document.getElementById(bg_div).style.display='block' ;
	var bgdiv = document.getElementById(bg_div);
	bgdiv.style.width = document.body.scrollWidth;	
	$("#"+bg_div).height($(document).height());
	$("#printdiv").html("");
	if(printdata!=null){
		var page = '<div style="page-break-after: always;"></div>';
		$.each(printdata,function(i,result){  
			var item=
				'<span style="text-align: center;">位置：'+result["whname"]+'</span><br/>'+
				'<span style="text-align: center;">类别：'+result["cdname"]+'</span><br/>'+
				'<img id="image" src="${base}/back/qrcodeimg.do?no='+result["no"]+'" /><br/>'+
				'<span style="text-align: center;">编号：'+result["no"]+'</span>';
				if((i+1)<printdata.length){
					item+=page;
				}
				$("#printdiv").append(item);
		})
	}
}
//关闭弹出层
function CloseDiv(show_div,bg_div)
{
	document.getElementById(show_div).style.display='none';
	document.getElementById(bg_div).style.display='none';
	$("#printdiv").html("");
};	
function printqr(){
	$("#printdiv").printArea();
}

</script>
	<div id="fade" class="black_overlay"></div>
	<div id="MyDiv" class="white_content">
		<div style="position: fixed;right: 15%;top: 11%;text-align: right; cursor: default; height: 40px;">
			<span style="font-size: 16px;">打印效果预览</span>
			<span style="font-size: 16px; border:1px; background:#b09de6" onclick="printqr()">打印</span>
			<span style="font-size: 16px; border:1px; background:#aa96e4" onclick="CloseDiv('MyDiv','fade')">关闭</span>
		</div>
		<div id="printdiv" style="text-align: center;"></div>
	</div>
	
	
	
	
</div>
</body>
</html>